class WidgetWorker < BackgrounDRb::MetaWorker
  set_worker_name :widget_worker
  def create(args = nil)
    # this method is called, when worker is loaded for the first time
  end
  
  def run
    hws = HubWidget.find(:all, :conditions => "code_files.name = 'background' AND code_files.view = 0", :include => {:widget => :code_files})
    t = Time.now
    logger.info "Found #{hws.length} hub widgets with background code"
    hws.each do |hw|
      hw.run_background
    end
    logger.info "Done! Took #{Time.now - t} seconds"
  end
end

